// function loadcalc(){
	
// 	// inputnames=["age","totalsavings", "annualspending", "annualincome", "swr", "incomerate","retirespending","stockpct","bondpct","cashpct","stockrtn","bondrtn","MCstockrtn","MCbondrtn"];
// 	// urlparamnames=["age", "initsav", "spend", "initinc", "wr", "ir", "retspend", "stockpct", "fixpct", "cashpct","stockrtn","bondrtn","MCstockrtn","MCbondrtn"];
// 	// defaultvals=[35,25000,45000,60000,4,1,40000,80,18,2,8.1,2.4,8.1,2.4];
	
// 	inputnames=["spending", "savings", "age", "years","stockpct","bondpct","cashpct","sexind","infind","efftaxrate","invstfees","incomestring","incomestartagestring","incomeendagestring","expensestring","expensestartagestring","expenseendagestring","showdeathind","showlowind","show2xind","show5xind"];
// 	urlparamnamesout=["spend","initsav","age","yrs","stockpct","bondpct","cashpct","sex","infl","taxrate","fees","income","incstart","incend","expense","expstart","expend","showdeath","showlow","show2x","show5x"];
// 	defaultvals=[40000,1000000,40,50,80,18,2,"M",1,0,.003,0,50,70,0,50,70,1,1,1,1];


// 	paramvals=[];

// 	// var defspend=40000;
// 	// var defsav=50000;
// 	// var defwr=4;
// 	thisURL = window.location.href;
// 	parseUrl = new URL(thisURL);
	
// 	for (var i=0;i<inputnames.length;i++){
// 		paramvals[i]=parseUrl.searchParams.get(urlparamnamesout[i]);

// 		if (paramvals[i]==null){
// 			paramvals[i]=defaultvals[i];
// 		}
// 	}

// 	// graph = (parseUrl.searchParams.get("graph")==null?"fix":parseUrl.searchParams.get("graph"));
// 	// secgraph = (parseUrl.searchParams.get("secgraph")==null?3:parseUrl.searchParams.get("secgraph"));

// 	// var stockrtn=(parseUrl.searchParams.get("stockrtn")==null?8.1:parseUrl.searchParams.get("stockrtn"));
// 	// var bondrtn=(parseUrl.searchParams.get("bondrtn")==null?2.4:parseUrl.searchParams.get("bondrtn"));
// 	// var MCstockrtn=(parseUrl.searchParams.get("MCstockrtn")==null?8.1:parseUrl.searchParams.get("MCstockrtn"));
// 	// var MCbondrtn=(parseUrl.searchParams.get("MCbondrtn")==null?2.4:parseUrl.searchParams.get("MCbondrtn"));

// 	// var sav = parseUrl.searchParams.get("sav");
// 	// var spend = parseUrl.searchParams.get("spend");
// 	// var wr= parseUrl.searchParams.get("wr");
// 	// if (sav == null){sav=defsav;}
// 	// if (spend==null){spend=defspend;}
// 	// if (wr==null){wr=defwr;}
// 	fullurl = "https://engaging-data.com/pages/scripts/deadandbroke/RBoD3.html?";

// 		for (var i=0;i<inputnames.length;i++){
// 			fullurl = fullurl+(i?"&":"")+inputnames[i]+"="+paramvals[i];
// 		}
		
// 	document.getElementById('graph').src = fullurl;
// }

function generateURL(){
// inputnames=["age","totalsavings", "annualspending", "annualincome", "swr", "incomerate","retirespending","stockpct","bondpct","cashpct"];
	varnames=["annualspend", "beginningstache", "startage", "retireyrs","stockparam","fixedparam","cashparam","sexind","infind","taxparam","feesparam","incomestring","incomestartagestring","incomeendagestring","expensestring","expensestartagestring","expenseendagestring","showdeathind","showbelowind","showtwoXind","showfiveXind","flexparam"];
	urlparamnames=["spend","initsav","age","yrs","stockpct","bondpct","cashpct","sex","infl","taxrate","fees","income","incstart","incend","expense","expstart","expend","showdeath","showlow","show2x","show5x","flexpct"];
	// defaultvals=[40000,1000000,40,50,80,18,2,0,".3%",0,50,70,0,50,70];
	
	paramvals=[];
	paramstring="";
	
	for (var i=0;i<varnames.length;i++){
		paramvals[i]=document.getElementById("graph").contentWindow[varnames[i]];
		// paramvals[i]=this[varnames[i]];
		console.log(paramvals[i]);
		if (paramvals[i]==undefined){
			// paramvals[i]="none";
		} else {
			paramstring=paramstring+(i?"&":"")+urlparamnames[i]+"="+paramvals[i];
		}
	}

	// secgraph=document.getElementById("graph").contentWindow["secondgraphSelect"].selectedIndex;

	var string="https://engaging-data.com/will-money-last-retire-early/?"+paramstring;
	// 	+paramvals[2]+"&initinc="+paramvals[3]+"&wr="+paramvals[4]*100+"&ir="+paramvals[5]*100+"&retspend="+paramvals[6]+"&stockpct="
	// 	+paramvals[7]*100+"&fixpct="+paramvals[8]*100+"&cashpct="+paramvals[9]*100+"&graph="+paramvals[10]+"&secgraph="+secgraph
	// 	+"&stockrtn="+paramvals[11]*100+"&bondrtn="+paramvals[12]*100+"&MCstockrtn="+paramvals[13]+"&MCbondrtn="+paramvals[14];
	history.pushState("", "", string);	
	console.log(string);
}
	
function resettoDefault(){
	document.getElementById('graph').src = "https://engaging-data.com/pages/scripts/deadandbroke/RBoD3.html";
}
